{% extends 'base.html' %}
{% block self_head_css_js %}
    <script src="/static/layer/layer.js"></script>
{% endblock %}
{% block content %}
<script>
    window.onload=init;
    function init() {
        showhide(2);
    }
    function showhide(n) {
        var box = document.getElementById("asset");
        box.className="active";
        var box = document.getElementById("cmdb");
        box.className="active";
    }
</script>

  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="alert alert-info alert-dismissible" style="display: {{ display_control }};">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <h4>{{ tips }}</h4>
        </div>
    </section>

    <!-- Main content -->

    <section class="content">

      <!-- Default box -->
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">添加主机条目</h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
              <i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
              <i class="fa fa-times"></i></button>
          </div>
        </div>
        <div class="box-body">
      <form action="{% url 'asset_add' %}" method="post">
        {% csrf_token %}
        {{ a_form.as_p }}
        <input type="submit" class="btn btn-primary" style="width: 60pt" value="提交">&nbsp;&nbsp;
        <a href="{% url 'cmdb' %}"> <li class="btn btn-primary" style="width: 60pt">返回</li></a>
{#        &nbsp;&nbsp;<li  id="idc_add" class="btn btn-success" style="width: 60pt" >机房 <i class="fa fa-plus-circle"></i></li>#}

          <br>
      </form>
        </div>
        <!-- /.box-body -->
        <div class="box-footer">
          <i class="fa fa-info-circle"></i> 请勿重复添加条目。
        </div>
        <!-- /.box-footer-->
      </div>
      <!-- /.box -->
    </section>

  </div>
<input id="handle_status" value="" hidden="hidden">

<script>
$('#idc_add').on('click', function(){
    layer.open({
    type: 2,
    title: '添加机房',
    closeBtn: 1,
    area: ['500px', '450px'],
    shadeClose: true, //点击遮罩关闭
    content: ['/cmdb/idc/add/mini/'],
    end:function(){
            var handle_status = $("#handle_status").val();
            if ( handle_status == '1' ) {
                layer.msg('提交成功！',{
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                },function(){
                    history.go(0);
                });
            } else if ( handle_status == '2' ) {
                layer.msg('提交失败！',{
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                },function(){
                    history.go(0);
                });
            }
        }
  });
});
</script>
{% endblock %}